package org.shoukaiseki.aqoeous.controller;

import org.shoukaiseki.aqoeous.token.TokenHolder;
import org.shoukaiseki.aqoeous.token.TokenUser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * org.shoukaiseki.aqoeous.controller.IndexController
 * <br>
 *
 * @author 蒋カイセキ    Japan-Tokyo  19-2-2 下午3:46<br>
 * ブログ http://www.shoukaiseki.top/<br>
 * E-メール jiang28555@Gmail.com<br>
 **/
@Controller
public class IndexController {


    @RequestMapping(value = "/")
    public String index(){
        return "login";
    }


    @RequestMapping(value = "/login")
    public String login(@RequestParam String username,
                        @RequestParam String password ){

        TokenUser tokenUser = new TokenUser();
        tokenUser.setUserId(1L);
        tokenUser.setUserName(username);
        TokenHolder.set(tokenUser);
        return "redirect:/index";
    }


    @RequestMapping(value = "/index")
    public String index(ModelMap mmap){
        TokenUser tokenUser = TokenHolder.get();
        mmap.put("tokenUser",tokenUser);
        return "/index";
    }

}
